#ifndef __CLOCK_H
#define __CLOCK_H
#include<iostream>
#include<cstdio>
#include<ctime>
#include<cstring>
#include<cstdlib>
#include<sys/time.h>
#include<unistd.h>


using namespace std;

class Clock
{
public:
	Clock() 
	{ 
		isClicked = false;
	}
	~Clock() { }
	void set_mode(int n)
	{
		mode = n;	
	}
	void click()
	{
		time(&rawtime);
		ptminfo = localtime(&rawtime);
		gettimeofday(&stime, NULL);
		if(isClicked==false)isClicked=true;

		strcpy(strTimeClicked_last, strTimeClicked);
		
		sprintf(strTimeClicked, "%02d-%02d-%02d %02d:%02d:%02d:%02ld",
					ptminfo->tm_year + 1900, ptminfo->tm_mon + 1, ptminfo->tm_mday,
					ptminfo->tm_hour , ptminfo->tm_min, ptminfo->tm_sec, stime.tv_usec/mode);
	}
	void printTime()
	{
		if(isClicked==true)
		{
			printf("%s", strTimeClicked);
		}
	}
//privatet:
	int mode=1000;
	//get s
	time_t rawtime;
	struct tm *ptminfo;
	//get us
	struct timeval stime;
	//empty check
	bool isClicked;
	//time string
	char strTimeClicked[50];
	char strTimeClicked_last[50];

};


#endif
